package com.yxp.manager.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yxp.manager.common.PageReqVo;
import com.yxp.manager.common.Pagination;
import com.yxp.manager.common.ServerResponse;
import com.yxp.manager.model.AccountModel;
import com.yxp.manager.mapper.AccountMapper;
import com.yxp.manager.modelVo.request.AccountPageReqVo;
import com.yxp.manager.modelVo.response.AccountPageRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    AccountMapper accountMapper;

    @RequestMapping("/getAccountById")
    public ServerResponse getAccountById() {
        LambdaQueryWrapper<AccountModel> accountWrapper = Wrappers.<AccountModel>lambdaQuery().eq(AccountModel::getId, 1);
        return ServerResponse.createBySuccess(accountMapper.selectOne(accountWrapper));
    }

    @RequestMapping("/getAccountList")
    public ServerResponse<List<AccountModel>> getAccountList() {
        LambdaQueryWrapper<AccountModel> accountWrapper = Wrappers.<AccountModel>lambdaQuery().eq(AccountModel::getId, 1);
        return ServerResponse.createBySuccess(accountMapper.selectList(accountWrapper));
    }

//    @RequestMapping("/getAccountListPage")
//    public ServerResponse<Pagination<AccountPageRespVo>> selectAccountByPage(@RequestBody AccountPageReqVo reqVo) {
//        Pagination<AccountPageRespVo> page = new Pagination<>(PageReqVo.getPage(reqVo),PageReqVo.getSize(reqVo));
//        Pagination<AccountPageRespVo> respVoPagination = accountMapper.selectAccountByPage(page, reqVo);
//        return ServerResponse.createBySuccess(respVoPagination);
//    }
}
